<!-- Horizontal Form -->
<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title">修改物资</h3>
    </div>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        <div class="box-body">
            <div class="form-group">
                <label for="wzid" class="col-sm-2 control-label">物资序号</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="wzid" id="wzid" placeholder="名称">
                </div>
            </div>
            <div class="form-group">
                <label for="wznameId" class="col-sm-2 control-label">物资名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="wzname" id="wznameId" placeholder="名称">
                </div>
            </div>
            <div class="form-group">
                <label for="wzkind" class="col-sm-2 control-label">物资种类</label>
                <span class="col-sm-10">
                <select name="wzkind1" id="wzkind1"
                        style="width: 500px; height: 38px; margin: -2px;"
                        onChange="changeF();">
						<option id='1' value='医用品'>医用品</option>
						<option id='2' value='防护用品'>防护用品</option>
						<option id='3' value='消杀用品'>消杀用品</option>
						<option id='4' value='测试仪器'>测试仪器</option>
						<option id='5' value='救护车辆'>救护车</option>
						<option id='6' value='救护用具'>救护用具</option>
				</select>
            </span>
                <span style="position:absolute;">
           <input type="text" class="form-control" name="wzkind" id="wzkind" placeholder="物资种类">

            </span>
            </div>
            <div class="form-group">
                <label for="wznumId" class="col-sm-2 control-label">物资数量</label>
                <div class="col-sm-10">
                    <input type="text" id="wznumId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="wzunitId" class="col-sm-2 control-label">物资单位</label>
                <div class="col-sm-10">
                    <input type="text" id="wzunitId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="manuId" class="col-sm-2 control-label">生产厂家</label>
                <div class="col-sm-10">
                    <input type="text" id="manuId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="startTimeId" class="col-sm-2 control-label">生产日期</label>
                <div class="col-sm-10">
                    <input type="text" id="startTimeId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="endTimeId" class="col-sm-2 control-label">到期时间</label>
                <div class="col-sm-10">
                    <input type="text" id="endTimeId" class="form-control">
                </div>
            </div>
        </div>
        <!-- /.box-body -->
        <div class="box-footer">
            <button type="button" class="btn btn-default btn-cancel">取消</button>
            <button type="button" class="btn btn-info pull-right btn-update" onclick="doUpdate()">修改</button>
        </div>
        <!-- /.box-footer -->
    </form>


</div>
<script type="text/javascript" src="bower_components/ztree/jquery.ztree.all.min.js"></script>
<script type="text/javascript" src="bower_components/layer/layer.js"></script>
<script type="text/javascript">
  $(".box-footer")
	  .on("click",".btn-cancel",doCancel)
    function doCancel(){
	var url="wzxx/sww_wzxx";
	$("#mainContentId").load(url);
  }
     $(".box-footer")
	  .on("click",".btn-save",doSaveOrUpdate)
 function doSaveOrUpdate(){
       debugger
	  //1.获取表单数据
	  var params=doGetEditFormData();
	  //2.定义url
	  var url="sww/doSaveObjects"
	    console.log(params);
	  //3.异步提交数据
	  $.post(url,params,function(result){
		  if(result.state==1){
			  alert(result.message);
			  doCancel();
		  }else{
			  alert(result.message);
		  }
	  });
  }



  function changeF() {
		document.getElementById('wzkind').value = document
				.getElementById('wzkind1').options[document
				.getElementById('wzkind1').selectedIndex].value;
	}

function doGetEditFormData(id){
	  var params={
        wzid:id,
		wzname:$("#wznameId").val(),
		wzkind:$("#wzkind").val(),
		wznum:$("#wznumId").val(),
		wzunit:$("#wzunitId").val(),
		manufacturer:$("#manuId").val(),
		startTime:$("#startTimeId").val(),
		endTime:$("#endTimeId").val()
	  }

	  return params;
  }
$(function(){
   // debugger
	 var data = $("#mainContentId").data("rowData");
	 if(data)doInitFormData(data);
 })


 function doInitFormData(data){
      debugger
     //console.log(data);
	 $(".typeRadio input[value='"+data.type+"']").prop("checked",true);
	 //初始化用户信息

	 $("#wznameId").val(data.wzname);
	 $("#wzkind").val(data.wzkind);
	 $("#wznumId").val(data.wznum);
	 $("#wzunitId").val(data.wzunit);
      $("#manuId").val(data.manufacturer);
     $("#startTimeId").val(data.startTime);
     $("#endTimeId").val(data.endTime);
 }

</script>
<script type="text/javascript">
     function doInitFormData1(data){
      //debugger
     //console.log(data);
	 //初始化用户信息
	 $("#wzid").val(data.wzid);
	 $("#wznameId").val(data.wzname);
	 $("#wzkind").val(data.wzkind);
	 $("#wznumId").val(data.wznum);
	 $("#wzunitId").val(data.wzunit);
	  $("#manuId").val(data.manufacturer);
     $("#startTimeId").val(data.startTime);
     $("#endTimeId").val(data.endTime);
 }
     function doUpdate(){
    //debugger
    var url="sww/doUpdateObject";
    var params={
        wzid:$("#wzid").val(),
		wzname:$("#wznameId").val(),
		wzkind:$("#wzkind").val(),
		wznum:$("#wznumId").val(),
		wzunit:$("#wzunitId").val(),
		manufacturer:$("#manuId").val(),
		startTime:$("#startTimeId").val(),
		endTime:$("#endTimeId").val()
	  }
    console.log(params);
    $.get(url,params,function(result){
		  alert(result);
		  doCancel();
	  });
  }



</script>

    
    
    
    
    
    
    
    